<?php
include_once($_SERVER['DOCUMENT_ROOT'] ."/include/user/inc.php");
include_once($_SERVER['DOCUMENT_ROOT'] ."/include/tucao/inc.php");
include_once($_SERVER['DOCUMENT_ROOT'] ."/include/mblog/inc.php");
include_once($_SERVER['DOCUMENT_ROOT'] ."/include/qq/inc.php");
include_once($_SERVER['DOCUMENT_ROOT'] ."/include/taobao/inc.php");
//所有的参数
$g_cgival 	= array();
//存储中间数据 非输出数据 可以不用
$g_pro	 	= array();
//要显示的数据 输出数据
$g_show 	= array();

function check_cgi_pro()
{		
	global $g_cgival, $g_pro, $g_show, $config;
	
	cgi::both($g_cgival["p"], "p", "");
	$g_cgival["p"] = intval($g_cgival["p"]);
	
	if($g_cgival["p"] < 1) $g_cgival["p"]=1;
	
	cgi::both($g_cgival["sex"], "sex", "0");
	$g_cgival["sex"] = string::un_html($g_cgival["sex"]);
	
	cgi::both($g_cgival["uid"], "uid", "");
	$g_cgival["uid"] = intval($g_cgival["uid"]);
	

}


function get_data()
{
	global $g_cgival, $g_pro, $g_show, $config;
	
	
//登录相关
	$user_info = new user_info();
	$is_login = $user_info->is_logined();
	$p = $g_show["p"] = $g_cgival["p"];
	$topic_id = $g_cgival["topic_id"] = $config["current_site_id"];
	if($is_login)
	{
		$user_detail_info = $user_info->get_cur_user_info();
	
		$uid = $user_detail_info["uid"];
		$user_nickname = $user_detail_info["user_nickname"];
		$g_show["is_logined"] = true;
		$g_show["current_user_info"] = $user_detail_info;
	}
	
	$g_show["channel"] = "mblog";
	$pcount = $g_cgival["pcount"] = 20;
	$p = $g_cgival["p"];
	$topic_id = $g_cgival["topic_id"] = $config['current_site_id'];
	$show_type = $g_cgival["show_type"];
	$status = 1;
	$sex = $g_cgival["sex"];
	

	$g_show["online"] = $online = $g_cgival["online"];
	$verified_type = $g_cgival["verified_type"];
	$db_mblog_video_content = new db_mblog_video_content();
	$g_show["uid"] = $uid = $g_cgival["uid"];
	$g_show["topic_id"] = $topic_id;
	$g_show["sex"] = $sex;
	
	if($topic_id)
	{
	
		$db_mblog_cron_topic_tag = new db_mblog_cron_topic_tag();
		$g_show["topic_info"]= $db_mblog_cron_topic_tag->get_mblog_cron_topic_tag_item_by_id($topic_id);
		
		
	}
	
	
	$mod_mblog = new mod_mblog();
	
	$db_mblog_want_content = new db_mblog_want_content();
	
	$list = $db_mblog_want_content->get_mblog_want_list_by_topic($p,$pcount,$topic_id,$sex,$verified_type,$online,$uid);
	$count = $db_mblog_want_content->get_mblog_want_count_by_topic($topic_id,$sex,$verified_type,$online,$uid);
	
	$create_uid_array =array();
	foreach($list as $key => $value)
	{
		$create_uid_array[] = $value["create_uid"];
	}
	
	$db_qq_user_info = new db_qq_user_info();
	$user_list = $db_qq_user_info->get_user_list_by_uids($create_uid_array);
	
	$user_array = array();
	foreach($user_list as $key => $value)
	{
		$user_array[$value["uid"]] = $value; 
	}
	
	foreach($list as $key => $value)
	{
		$list[$key]["user_info"] = $user_array[$value["create_uid"]];
	}
	
	
	$uid_array = array();
	$mid_array = array();

	
	$uid_array = array_unique($uid_array);
	$mblog_cache_v2 = new mblog_cache_v2();

	
	
	$db_mblog_cron_topic_tag = new db_mblog_cron_topic_tag();
	
	$g_show["count"] = $count;
	$g_show["list"] = $list;
	
	if($uid)
	{
		$Pages = new Pages($g_show["count"],$g_cgival["p"],$g_cgival["pcount"]);
		$g_show["page_bar"] = $Pages->getLinks_static("/want/user_{$uid}_replacepage.html",8);
	
	}
	else
	{
		$Pages = new Pages($g_show["count"],$g_cgival["p"],$g_cgival["pcount"]);
		$g_show["page_bar"] = $Pages->getLinks_static("/want/index_{$sex}_replacepage.html",8);
	
	}
	
	if($uid)
	{
		$db_qq_user_info = new db_qq_user_info();
		$item_user_info = $db_qq_user_info->get_qq_user_info_item_by_uid($uid);
		$title_desc = $item_user_info["user_nickname"]."在求组队_";
	}
	
	$current_site_name = $config["current_site_name"];
	$g_show["page_keywords"]  = "{$item_user_info["user_nickname"]},{$current_site_name}组队,{$current_site_name}求组队,{$current_site_name}怎么玩,{$current_site_name}找人一起,{$current_site_name}求带,{$current_site_name}大神";
	if($config["site_alias"][$config["current_site_id"]])
	{
		foreach($config["site_alias"][$config["current_site_id"]] as $value)
		{
			$g_show["page_keywords"]  = ",{$value}组队,{$value}求组队,{$value}怎么玩,{$value}找人一起,{$value}求带,{$value}大神";
			
		}
	}
	
	$g_show["page_desc"]  = "{$title_desc}{$current_site_name}组队_游戏美图_最有意思的游戏玩家分享平台";
	$g_show["page_title"] = "{$title_desc}{$current_site_name}组队_游戏美图_最有意思的游戏玩家分享平台";
	
	
	$g_show["topic_id"] = $topic_id;
	$g_show["show_type"] = $show_type;
	$g_show["pubu_show_type"] = "video";
	
	
	$db_taobao_goods_item = new db_taobao_goods_item();
	$tao_tuijian = $db_taobao_goods_item->get_taobao_list_by_site_id(1,10);
	
	$g_show["tao_tuijian"] = $tao_tuijian;
	
	
	$db_mblog_video_content = new db_mblog_video_content();
	
}

try {
	$g_show['error'] = 0;
	$g_show['errmsg'] = "";
	check_cgi_pro();
	get_data();
	$g_show["hide_shadow"] = true;
	
} catch (Exception $e) {
	$g_show['error'] = 1;
	$g_show['errmsg'] = $e->getMessage();
}

show_pro();


exit;

function show_pro()
{
	global $g_cgival, $g_pro, $g_show, $config;

	$smarty = p_get_smarty();	
	$smarty->assign("g_show", $g_show);
	if (isset($_GET["debug"]))
	{
		print_r($g_show);
	}
	
	//$smarty->display("want/m_index.html");
	$smarty->display("want/index.html");
	
	unset($g_cgival);
	unset($g_pro);
	unset($g_show);
	unset($config);
	
}

